using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using XNAGameEngine;
using XNAGameEngine.Audio;
using XNAGameEngine.Collision;
using XNAGameEngine.DataStructures;
using XNAGameEngine.GameObject;
using XNAGameEngine.GameState;
using XNAGameEngine.GUI;
using XNAGameEngine.Input;
using XNAGameEngine.Logs;
using XNAGameEngine.Pathfinding;

namespace XNAGame
{
    internal static class Program
    {
        /// <summary>
        /// The main entry point for the Game.
        /// </summary>
        private static void Main(string[] args)
        {
            using (Game game = new GameEngine())
            {
                game.IsMouseVisible = true;
                //GameEngine.GraphicsDeviceManager.PreferredBackBufferWidth = 1920;
                //GameEngine.GraphicsDeviceManager.PreferredBackBufferHeight = 1080;
                //GameEngine.GraphicsDeviceManager.IsFullScreen = true;

                new ManagerMouseEvents(game, new ManagerInput(game));
                new ManagerGameObject2D(game);
                new ManagerAudio2D(game);
                new ManagerGUI(game);
                new ManagerCollision(game);

                RegisterGUILayouts();
                RegisterGameStates();
                RegisterGameStateTransitions();
                RegisterGameObjects();

                game.Run();
            }
        }

        private static void RegisterGameStates()
        {
            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "TitleState", typeof(TitleState));
            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "InfoState", typeof(InfoState));
            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "NewGameState", typeof(NewGameState));
            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "WorldMapState", typeof(WorldMapState));
            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "Battle1State", typeof(Battle1State));
            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "GameOverState", typeof(GameOverState));
            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "GameOverLoseState", typeof(GameOverLoseState));

            GameEngine.GetService<IManagerGameState>().RegisterGameState(
                "DemoState", typeof(Demostate));
        }

        private static void RegisterGameStateTransitions()
        { }

        private static void RegisterGameObjects()
        {
            GameEngine.GetService<IManagerGameObject2D>().RegisterGameObject(
                "Warrior", typeof(Warrior));
            GameEngine.GetService<IManagerGameObject2D>().RegisterGameObject(
                "PlayerParty", typeof(Player_Party));
            GameEngine.GetService<IManagerGameObject2D>().RegisterGameObject(
                "AIParty", typeof(AI_Party));
            GameEngine.GetService<IManagerGameObject2D>().RegisterGameObject(
                "Tile", typeof(tile));
            GameEngine.GetService<IManagerGameObject2D>().RegisterGameObject(
                "BattleMenu", typeof(battlemenu));

        }

        private static void RegisterGUILayouts()
        {
            GameEngine.GetService<IManagerGUI>().RegisterGUILayout(
                "TitleGUI", typeof(TitleGUI));
            GameEngine.GetService<IManagerGUI>().RegisterGUILayout(
                "InfoGUI", typeof(InfoGUI));
            GameEngine.GetService<IManagerGUI>().RegisterGUILayout(
                "WorldMapGUI", typeof(WorldMapGUI));
            GameEngine.GetService<IManagerGUI>().RegisterGUILayout(
                "NewGameGUI", typeof(NewGameGUI));
            GameEngine.GetService<IManagerGUI>().RegisterGUILayout(
                "GameOverGUI", typeof(GameOverGUI));
            GameEngine.GetService<IManagerGUI>().RegisterGUILayout(
                "ForceGameOverGUI", typeof(ForceGameOverGUI));
            GameEngine.GetService<IManagerGUI>().RegisterGUILayout(
                "DemoGUI", typeof(DemoGUI));
        }
    }
}